package com.intelligentclass.services;

import com.intelligentclass.entity.Notice;
import com.intelligentclass.repositories.NoticeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeService {

    @Autowired
    private NoticeRepository noticeRepository;

    // 获取所有公告
    public List<Notice> getAllNotices() {
        return noticeRepository.findAll();
    }

    // 根据 noticeCid 获取公告
    public List<Notice> getNoticesByCid(String cid) {
        return noticeRepository.findByNoticeCid(cid);
    }

    // 新增公告
    public Notice addNotice(Notice notice) {
        return noticeRepository.save(notice);
    }
}
